import uvicorn
from app import app
from app.db import init_db
from app.logger import logger

if __name__ == "__main__":
    try:
        # 初始化数据库
        init_db()
        logger.info("数据库初始化成功")
        
        # 启动应用
        uvicorn.run(
            "app:app",
            host="0.0.0.0",
            port=8000,
            reload=True,
            log_level="info"
        )
    except Exception as e:
        logger.error(f"应用启动失败: {str(e)}")
        raise 